﻿<%@ Page Title="Danh sách các danh mục bài viết" Language="C#" AutoEventWireup="true" CodeBehind="CategoryList.aspx.cs" Inherits="VIT.Web.Admin.CategoryList" %>
<%@ Register Assembly="VIT.Web.Controls" Namespace="VIT.Web.Controls" TagPrefix="VIT" %>

<asp:Content ID="HeadContent" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript" src="<%=URLRoot %>Admin/Includes/VIT.js"></script>
</asp:Content>
<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="server">
    <form id="aspnetForm" runat="server">

    <asp:Panel ID="pnAlert" runat="server">
        <p class="msg error" id="lblEmpty" runat="server" visible="false">Phải xóa tất cả nhóm con và bài viết trước khi xóa nhóm cha</p>
	</asp:Panel>

    <div>
        <div class="select">
            Ngôn ngữ: <asp:DropDownList ID="ddlLang" runat="server" autopostback="true" onselectedindexchanged="ddlLang_SelectedIndexChanged"></asp:DropDownList>
            &nbsp;
            Danh mục:
            <select id="category_parentid" name="category_parentid">
                <option value="0"> -- None -- </option>
                <%=this.genOption%>
            </select>
        </div>
        <div class="toolbar">
            <asp:Button ID="Filter" runat="server" ToolTip="Lọc dữ liệu" CssClass="icon-32-filter" BorderStyle="None" style="margin:10px" OnClick="Filter_Click"/>
            <VIT:Submit ID="Insert" runat="server" Function="Category_Insert" ToolTip="Thêm" CssClass="icon-32-add" BorderStyle="None" OnClick="Insert_Click"/>
            <VIT:Submit ID="Published" runat="server" Function="Category_Modify" ToolTip="Bật" CssClass="icon-32-apply" BorderStyle="None" OnClick="Published_Click" OnClientClick="return hasCheck('itemCheckbox','Vui lòng chọn danh mục để bật.');"/>
            <VIT:Submit ID="UnPublished" runat="server" Function="Category_Modify" ToolTip="Tắt" CssClass="icon-32-unapply" BorderStyle="None" OnClick="UnPublished_Click" OnClientClick="return hasCheck('itemCheckbox','Vui lòng chọn danh mục để tắt.');"/>
            <VIT:Submit ID="Delete" runat="server" Function="Category_Delete" ToolTip="Xóa" CssClass="icon-32-delete" BorderStyle="None" OnClick="Delete_Click" OnClientClick="return hasCheck('itemCheckbox','Vui lòng chọn danh mục để xóa.')  && confirm('Xóa danh mục được chọn');"/>
        </div>
    </div>
    <div class="clr"></div>

    <div>
        <table>
            <asp:ObjectDataSource ID="ODS" runat="server" SortParameterName="SortColumn" SelectMethod="GetData" TypeName="VIT.Web.Admin.CategoryList"
                onselecting="odsProducts_Selecting">  
                <SelectParameters>  
                   <asp:Parameter Name="selectedId" Type="String" />  
                </SelectParameters>                 
            </asp:ObjectDataSource>
            <asp:ListView ID="ListView" runat="server" DataSourceID="ODS">
                <LayoutTemplate>
                    <thead>
	                    <tr>
                            <th width="2%">#</th>
		                    <th width="2%">
			                    <input type="checkbox" name="toggle" id="toggle" onclick="checkAll('toggle', 'itemCheckbox')"/>
	                        </th>                    
		                    <th width="20%">
                                <asp:LinkButton ID="lnkTitle" runat="server" CommandName="Sort" CommandArgument="Title" Text="Tiêu đề" />
                            </th>
		                    <th width="10%">Danh mục cha</th>
		                    <th>Mô tả</th>
                            <th width="10%">
                                <asp:LinkButton ID="lnkOrders" runat="server" CommandName="Sort" CommandArgument="Orders" Text="Thứ tự" />
                            </th>
		                    <th width="10%">
                                <asp:LinkButton ID="lnkPublished" runat="server" CommandName="Sort" CommandArgument="Published" Text="Hiển thị" />
                            </th>
                            <th>ID</th>
		                    <th width="5%">Sửa</th>
	                    </tr>			
                    </thead>
                    <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
                </LayoutTemplate>
                    
                <ItemTemplate>
                    <tr class="row<%#Container.DataItemIndex%2 %>">
		                <td align="center"><%#Container.DataItemIndex%></td>
	                    <td align="center">
		                    <input type="checkbox" name="itemCheckbox" value="<%#Eval("Id")%>" />
                        </td>
	                    <td align="left"><%#Eval("Title")%></td>
	                    <td align="center"><%#Eval("ParentId")%></td>
	                    <td align="left"><%#Eval("Description")%></td>
	                    <td align="center">
                            <VIT:LinkSubmit ID="btnOrderUp" Function="Category_Modify" OnClick="updateOrder_Click" CssClass="btn" runat="server" Param='<%#Eval("Id")+"|-"%>'><img src="<%=URLRoot %>Admin/Includes/icons/uparrow.png"/></VIT:LinkSubmit>
                            <span><%#Eval("Orders")%></span>
                            <VIT:LinkSubmit ID="btnOrderDown" Function="Category_Modify" OnClick="updateOrder_Click" CssClass="btn" runat="server" Param='<%#Eval("Id")+"|+"%>'><img src="<%=URLRoot %>Admin/Includes/icons/downarrow.png"/></VIT:LinkSubmit>
                        </td>
	                    <td align="center">
                            <VIT:LinkSubmit ID="changePublish" Function="Category_Modify" OnClick="changePublish_Click" runat="server" Param='<%#Eval("Id")+"|"+Eval("Published")%>'>
                                <img alt="<%#Eval("Published")%>" src="<%#URLRoot+(Eval("Published").ToString() == "True" ? "Admin/Includes/icons/tick.png" : "Admin/Includes/icons/publish_x.png")%>" />
                            </VIT:LinkSubmit>
                        </td>
		                <td align="center"><%#Eval("id")%></td>	
                        <td align="center"><a href='CategoryEdit.aspx?sId=<%#Eval("id")%>'>Sửa</a></td>
                    </tr>
                </ItemTemplate> 
            </asp:ListView>
        </table>
    </div>
</form>
    <script type="text/javascript">
        $("#aside ul li#CategoryList").addClass("submenu-active");
    </script>
</asp:Content>
